package com.itheima.exception;

import com.itheima.pojo.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;
@Slf4j
@RestControllerAdvice//标识是一个处理全局异常的类
public class GIobalExceptionHandler {
    @ExceptionHandler
    public Result exceptionHandler(Exception e) {
        log.error("异常信息日志:{}",e.getMessage());
        return Result.error("您的操作有误请重试");
    }
    @ExceptionHandler
    public Result exceptionHandler(BusinessException e) {
        log.error("部门异常信息",e.getMessage());
        return Result.error("不能删除");
    }
}
